/* ****************************************************************************
 * Author: 671643387
 * Date: 2015/3/19
 * ***************************************************************************/

Ext.define("sggm.view.SendFighterWindow", {
    extend: "Ext.Window",
    alias: "widget.sendFighterWindow",
    title: "发放武将",
    width: 300,
    height: 150,
    modal: true,
    layout:"form",
    labelWidth:45,
    plain:true,
    bodyStyle:"padding:5px",
    buttonAlign: "center",
    items: [{
        xtype: "combo",
        name: "id",
        fieldLabel: "武将名字",
        store: new Ext.data.ArrayStore({
            fields: ['value','text'],
            data: []
        }),
        editable: true,
        valueField: "value",
        displayField: "text",
        triggerAction: "all",
        typeAhead : true,
        mode : 'local',
        selectOnFocus : true,
        listeners : {
            'beforequery':function(e){

                var combo = e.combo;
                if(!e.forceAll){
                    var input = e.query;
                    // 检索的正则
                    var regExp = new RegExp(".*" + input + ".*");
                    // 执行检索
                    combo.store.filterBy(function(record,id){
                        // 得到每个record的项目名称值
                        var text = record.get(combo.displayField);
                        return regExp.test(text);
                    });
                    combo.expand();
                    return false;
                }
            }
        }
    }, {
        xtype: "numberfield",
        name: "num",
        fieldLabel: "数量",
        minValue: 1,
        hideTrigger: true
    }],
    buttons: [{
        text: "发放",
        action: "sendFighter"
    }]
});